package com.excellence.datamodel;


import com.excellence.staticdata.ReturnCodeConstants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author 徐瑞琪
 */
@Component
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result {
    //响应码
    private Integer code;
    //响应消息
    private String msg;
    //响应数据
    private Object data;

    //响应成功
    public static Result success() {
        return new Result(ReturnCodeConstants.SUCCESS, "响应成功", null);
    }

    public static Result success(Integer code, String message) {
        return new Result(code, message, null);
    }

    public static Result success(Object data) {
        return new Result(ReturnCodeConstants.SUCCESS, "响应成功", data);
    }

    public static Result success(Integer code, String msg, Object data) {
        return new Result(code, msg, data);
    }

    //响应失败
    public static Result error() {
        return new Result(ReturnCodeConstants.ERROR, "系统错误，响应失败", null);
    }

    public static Result error(Integer code, String msg) {
        return new Result(code, msg, null);
    }
}
